package com.tianluo.tianluobookstore.config;


import com.alipay.api.AlipayClient;
import com.alipay.api.DefaultAlipayClient;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class AlipayConfig {

    @Value("${alipay.app-id}")
    private String appId;

    @Value("${alipay.private-key}")
    private String privateKey;

    @Value("${alipay.public-key}")
    private String publicKey;

    @Value("${alipay.gateway}")
    private String gateway;

    @Bean
    public AlipayClient alipayClient() {
        return new DefaultAlipayClient(
                gateway, // 支付宝网关
                appId,   // APPID
                privateKey, // 应用私钥
                "json",  // 返回格式
                "UTF-8", // 字符集
                publicKey, // 支付宝公钥
                "RSA2"   // 签名算法
        );
    }
}
